/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cjava.system.dao.hibernate;

import java.util.ArrayList;
import java.util.List;
import org.cjava.system.dao.interfac.IMeetingDao;
import org.cjava.system.dao.util.GenericEntityDao;
import org.cjava.system.model.Meeting;
import org.cjava.system.model.MeetingBusinessAssociate;

/**
 *
 * @author max
 */
public class MeetingDao extends GenericEntityDao<Meeting, Long> implements IMeetingDao{

    @Override
    public List listHQL(String hql, int lazyChargeOption, Object object) throws Exception {
        List listHQL = null;
        
        if( lazyChargeOption == 1 ) {
            List<MeetingBusinessAssociate> list = (List<MeetingBusinessAssociate>) object;
            List<Integer> listIds = new ArrayList();
            for (int i = 0; i < list.size(); i++) {
                listIds.add(list.get(i).getIdMeeting().getId()); //AGREGANDO ID'S A LA LISTA                
            }
            listHQL = getSessionFactory().getCurrentSession()
                .createQuery(hql)
                .setParameterList("list", listIds)
                .list();
        }
            
        return listHQL;
    }
    
    
    
}
